<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>添加房间</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css" />
</head>
<body>
<style>
    .w340{width:340px!important;}
</style>
<div class="page-content-wrap">
    <form class="layui-form">
        <div class="layui-tab" style="margin:0 50px 70px 30px;">
            <div class="layui-tab-content">
                <div class="layui-tab-item"></div>
                <div class="layui-tab-item layui-show">
                    <input type="hidden" name="id" id="id" value="${wxWbRoom.id}" >
                    <input type="hidden" name="applyId" id="applyId" value="${wxWbRoom.applyId}" >
                    <div class="layui-form-item">
                        <label class="layui-form-label">房间所在场地：</label>
                        <div class="layui-input-block">
                            <input type="text" name="parentName" placeholder="" readonly value="${wxWbRoom.bulidName!'主菜单'}" autocomplete="off"
                                   class="layui-input">
                            <input type="hidden" name="bulidId" id="bulidId" value="${wxWbRoom.bulidId}" >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;房间号：</label>
                        <div class="layui-input-block w340">
                            <input type="text" name="roomNum"  id="roomNum" value ="${wxWbRoom.roomNum}" required  lay-verify="required" placeholder="请输入房间号名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;房间名称：</label>
                        <div class="layui-input-block w340">
                            <input type="text" name="roomName" id="roomName" value ="${wxWbRoom.roomName}" required  lay-verify="required" placeholder="请输入房间名称名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;房间楼层：</label>
                        <div class="layui-input-block w340">
                            <input type="text" name="floorNum"  id="floorNum" value ="${wxWbRoom.floorNum}" required  lay-verify="required" placeholder="请输入房间楼层名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;房间类型：</label>
                        <div class="layui-input-block w340">
                            <select name="roomType" id="roomType"   required  lay-verify="required"  lay-filter="roomType">
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;二维码：</label>
                        <div class="layui-input-block cy-uploadpic-ctn" id="twoDimension" style=" float:left;margin-left:0!important;position:relative;pointer-events:none;"></div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;排序：</label>
                        <div class="layui-input-block w340">
                            <input type="text" name="sort" id="sort" value ="${wxWbRoom.sort}"  required lay-verify="required|number" placeholder="请输入排序" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">&nbsp;备注：</label>
                        <div class="layui-input-block w340">
                            <input type="text" name="remarks"  id="remarks" value ="${wxWbRoom.remarks}"   placeholder="请输入备注" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <div class="layui-form-item layui-pop-btn">
            <div class="">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="submitBtn">提交</button>
                <button type="button" id="cancel" class="layui-btn layui-btn-primary">取消</button>
                <button type="button" style="display: none;" id="save" class="layui-btn layui-btn-primary"></button>
            </div>
        </div>
    </form>
</div>

<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['form', 'jquery', 'laydate', 'layer', 'dialog','baseutil','page','fileUtil'], function() {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery,
            baseutil = layui.baseutil,
            dialog = layui.dialog,
            fileUtil=layui.fileUtil;
        var page = layui.page;
        page.initDict("roomType",function (dictData) {
            page.showDict($("#roomType"), page.aceeptDictContentList(dictData, "roomType"),"请选择",'${wxWbRoom.roomType}');
        });

        //初始化附件控件
        fileUtil.uploadImage('twoDimension','wbroom','${wxWbRoom.twoDimension}');
        //监听上级菜单
        $('input[name=parentName]').bind('click', function () {
            dialog.popUpPage('选择所在场所', '/base/selector/single?url=/wb/wxwbbulid/dTreeListRoom?applyId=${wxWbRoom.applyId}', '450px', '600px', function (layer, index) {
                var body = layer.getChildFrame('body', index);
                body.find("#save").bind("click", function () {
                    parent.layer.close(index);
                    var parentId = body.find("#resultId").val();
                    var parentName = body.find("#resultName").val();
                    if ('${wxWbBulid.id}' !== parentId) {
                        $('input[name=parentId]').val(parentId);
                        if (isBlank(parentId)) {
                            $('input[name=parentName]').val('主场地');
                        } else {
                            $('input[name=parentName]').val(parentName);
                        }
                    }
                });
                body.find("#cancel").bind("click", function () {
                    parent.layer.close(index);
                });
            });
        });

        //监听提交
        form.on('submit(submitBtn)', function(data){
            baseutil.post("/work/wb/wxwbroom/addOrUpdate",data.field,function (result) {
                dialog.msg(result.data);
                $("#save").click();
            });
            return false;
        });
    });
</script>
</body>

</html>